<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?>
<?
	if (sizeof($basket['basket']) > 0) {
		?>
		<table cellspacing='0' cellpadding='0' class='basket_table'>
			<tr>
				<th>№</th>
				<th>Код</th>
				<th>Наименование товара</th>
				<th>Количество</th>
				<th>Наличие товара</th>
				<th>Цена</th>
				<? if (!$return) { ?>
					<th>Удалить</th>
				<? } ?>
			</tr>
		<?
		$i = 0;
		foreach ($basket['basket'] as $key => $item) {
			$item_link = $this->catalog_service_model->get_item_link($key);
			$image = $this->db->select()->from('catalog_images')->where('photo_item', $key)->where('photo_main', '1')->get()->row_array();
			$i++;
			$bg_style = '';
			if(($i%2) != 0){
				$bg_style = 'style="background: #b7d7ee;"';
			} else {
				$bg_style = 'style="background: #d3eafa;"';
			}
			echo "<tr ".$bg_style.">";
				echo "<td style='width: 30px;'>";
					echo $i;
				echo "</td>";
				echo "<td style='text-align: center;'>";
					echo $item['item_code'];
				echo "</td>";
				echo "<td>";
					echo "<div><a href='/catalog/".$key."/' ".(sizeof($image) > 0?"rel='".$key.":".$image['photo_file']."'":"")." class='can_preview_item'>".$item['name']."</a></div>";
//					echo "<div><p ".(sizeof($image) > 0?"rel='".$key.":".$image['photo_file']."'":"")." class='can_preview_item'>".$item['name']."</p></div>";
				echo "</td>";
				echo "<td style='text-align: center; width: 60px; '>";
				if ($return)
					echo $item['count'];
				else
					echo "<input type='text' value='".$item['count']."' class='number_of_item' rel='".$key."' />";
				echo "</td>";
				echo "<td>";
//				echo "Наличие товара";
				if(tonum($item['have']) > 0) {
					echo 'В наличии';
				} else {
					echo 'Под заказ';
				}
				echo "</td>";
				echo "<td style='width: 100px;'>";
					echo tonum($item['price'])." руб.";
//
//				if (!$return) {
//					echo "<span class='postpaid_prices'>".tonum($item['price'])." руб.</span>";
//					echo "<span class='prepaid_prices'>".tonum($item['price2'])." руб.</span>";
//				} elseif ($return == true && $payment_selected == "prepaid") {
//					echo "<span class='prepaid_prices'>".tonum($item['price2'])." руб.</span>";
//				} elseif ($return == true && $payment_selected == "postpaid") {
//					echo "<span class='postpaid_prices' style='display: block;'>".tonum($item['price'])." руб.</span>";
//				}
				echo "</td>";
				if (!$return) {
					echo "<td style='width: 30px;'>";
						echo "<a href='/basket/delete/".$key."/' onclick='return confirm(\"Вы уверены что хотите удалить позицию?\");'><img src='/data/i/basket_del.png' alt='Удалить товар' title='Удалить товар' /></a>";
					echo "</td>";
				}
			echo "</tr>";

		}
		?>
		</table>
		<span class='fr hidden update_basket_link'>&nbsp;&nbsp;<a href='#' onclick='return false;'>Обновить корзину</a></span>
		<span class='fl'><a href='/basket/erase/'>Очистить корзину</a></span>
		<span class='fr' style='font-size: 15px;color: #0e0e0e;'>Общая сумма: <?=tonum(($payment_selected == "prepaid")?$basket['sum2']:$basket['sum'])?> рублей</span>
		<br class="cc" />
		<?
//		if (!$return) {
		echo "<div class='clear_quickform'>".$form."</div>";
//		echo "<br class='cc'/>";
		echo $text;
		echo "<br class='cc'/>";
//		}

	} else {
		echo showmenotice('Корзина пуста');
	}
?>